Skip to content

feat: Binding url citation metadata for event#1105

Open
flex-myeonghyeon wants to merge 3 commits intogoogle:mainfrom
flex-myeonghyeon:feat-binding-url-citation-metadata
Open

feat: Binding url citation metadata for event#1105
flex-myeonghyeon wants to merge 3 commits intogoogle:mainfrom
flex-myeonghyeon:feat-binding-url-citation-metadata

Conversation

@flex-myeonghyeon
Copy link
Copy Markdown

@flex-myeonghyeon flex-myeonghyeon commented Apr 1, 2026

Summary

  • Bind URL citation metadata to events when processing model responses
  • Extract and attach citation source URLs from grounding metadata to the corresponding event
  • Enables downstream consumers to access citation information directly from events

Test plan

  • Verify that citation metadata is correctly bound to events when URL citations are present
  • Verify that events without citation metadata are unaffected
  • Run existing unit tests to confirm no regressions

🤖 Generated with Claude Code

이 작업을 진행하는데 사용된 프롬프트
https://github.com/flex-myeonghyeon/adk-java 로 dc81846cc58c367dc72dab0f0eb264a8e5b4cdaf 체리픽 하고 PR 올려줘

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 1, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@flex-myeonghyeon flex-myeonghyeon marked this pull request as ready for review April 1, 2026 18:18
@glaforge
Copy link
Copy Markdown
Contributor

glaforge commented Apr 7, 2026

As a point of reference: in Python, the citation metadata is kept at the level of the equivalent LlmResponse object.
https://github.com/google/adk-python/blob/bbad9ec64ce1617bc45148de97e6246752845b98/src/google/adk/models/llm_response.py#L132

Wouldn't that be a better place for holding the citation metadata information?
Wouldn't that suit your need to have access to this metadata?

@flex-myeonghyeon
Copy link
Copy Markdown
Author

@glaforge
That is correct. First of all, I have added the citationMetadata property to the LlmResponse class.

Regarding your question, I believe you were asking about adding the property to the Event class. Since the Event class already contains groundingMetadata, I thought citationMetadata belonged at the same level of information and added it there as well:

private @Nullable GroundingMetadata groundingMetadata;

Do you think it should only be added to LlmResponse? If so, I will remove it from the Event class. Please let me know your thoughts.

@glaforge
Copy link
Copy Markdown
Contributor

glaforge commented Apr 7, 2026

@flex-myeonghyeon Hmmm... That's interesting...
I was pointing at Python to see what they had done there, but their event derives from llm response which has that citation metadata. But in Java, our Event class doesn't extend LlmResponse at all.
And indeed, I also noticed that GroundingMetadata was on Event, so CitationMetadata could very well have its place there.

I'm also curious: what lead you to this pull request? When/how did you need the citation metadata? What was the use case?

@flex-myeonghyeon
Copy link
Copy Markdown
Author

@glaforge
I am currently using the GoogleSearchAgentTool.

public class GoogleSearchAgentTool extends AgentTool {

When the GoogleSearchAgentTool is used in an ADK response, I wanted to be able to verify the search information that was referenced. My primary goal is to validate the basis of the response, but I also intend to pass this as citation information to the client if needed.

While I noticed that the Event class already provides groundingMetadata, I realized that it was missing citationMetadata. That is why I decided to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants